import axios from "axios"

export default {
    create(data) {
        return axios.post("/post/create",data)
    },
    getPostById(id) {
        return axios.get(`/post/${id}`)
    },
    like(id) {
        return axios.post(`/postLike/${id}`)
    },
    cacelLike(id) {
        return axios.delete(`/postLike/${id}`)
    },
    collect(id) {
        return axios.post(`/collection/${id}`)
    },
    cancelCollect(id) {
        return axios.delete(`/collection/${id}`)
    },
    fetchPostList(data) {
        return axios("/post/page",{
            params: data,
            method:"POST"
        })
    },
    listByUser(data) {
        return axios('/post/listByUser',{
            params:data,
            method:'POST'
        })
    }
    ,
    fetchHot(data=null) {
       
        return axios("/post/hot",{
            params: data,
            method:"POST"
        })
    },
    getCollectionByUser(data) {
        return axios(`/collection/getCollectionByUser`,{
            params: data,
            method:"POST"
        
        })
    }
    ,
    getViewRecords(data) {
        return axios(`/viewRecord/page`,{
            params:data,
            method:"POST"
        })
    },
    deleteViewRecord(id) {
        return axios.delete(`/viewRecord/${id}`)
    },
    search(data) {
        return axios({
            method:"POST",
            params:data,
            url:"/post/search"
        })
    },
    deletePost(id) {
        return axios.delete(`/post/${id}`)
    }
}